package cn.layou.thread;

import java.io.IOException;

/**
 * this逸出(对象半初始化状态，变量初始化会经过默认值、和初始值和赋值给this三个状态，当对象被赋值为默认值还未被赋值为初始值的状态成为对象的半初始化状态,)
 *
 * @author layou
 * @date 2021-04-16
 **/
public class T04_ThreadThisEscape {
    private int number = 8;

    public T04_ThreadThisEscape() {
        //输出可能为0，即为对象半初始化状态时
        //不要在构造方法里启动线程
        new Thread(() -> System.out.println(this.number)).start();
    }

    public static void main(String[] args) throws IOException {
        new T04_ThreadThisEscape();
        System.in.read();
    }
}
